<include file="../Public/_header.html" />
<div class="so_main">
<php>
	//dump($pagedata);
</php>
  
			<!-------- 搜索开始 -------->
		  <div id="search_div" rel='0'>
		  	<div class="page_tit">
		  		搜索订单[ <a href="javascript:void(0);" onclick="_show_searcharea();">隐藏</a> ]
		  	</div>
				
				<div class="sform">
					<form method="post" action="{:U('/Order/index')}" id="searchForm">
						<input id="pno" name="pno" type="hidden" value="1">
						<dl>
					    	
					      	<span>订单编号：</span>
					        <input id="search_orderId" name="search_orderId" type="text" value="{$search_orderId}">
					      
					      	<span>送者手机：</span>
						    <input id="search_sendermobile" name="search_sendermobile" type="text" value="{$search_sendermobile}">
					      	
							<span>是否支付：</span>
					      	<input name="search_ispay" type="radio" value="all" <eq name="search_ispay" value="all">checked</eq>>全部
					        <input name="search_ispay" type="radio" value="pay" <eq name="search_ispay" value="pay">checked</eq>>是
					        <input name="search_ispay" type="radio" value="unpay" <eq name="search_ispay" value="unpay">checked</eq>>否
					        <input name="search_goods_id" id="search_goods_id" type="hidden" value="{$search_goods_id}">
							<span>是否有效：</span>
					      	<input name="search_enable" type="radio" value="all" <eq name="search_enable" value="all">checked</eq>>全部
					        <input name="search_enable" type="radio" value="Y" <eq name="search_enable" value="Y">checked</eq>>是
					        <input name="search_enable" type="radio" value="N" <eq name="search_enable" value="N">checked</eq>>否
					    </dl>	
					    <dl>
					    	<span>货架编号：</span>
					        <input id="search_shelfId" name="search_shelfId" type="text" value="{$search_shelfId}">
					      	<php>if(!empty($search_shelfId)){
					      			$_tmp_pinfo = getProductInfoByShelfId($search_shelfId);
					      			$search_partner_id=$_tmp_pinfo['partner_id'];
					      			$search_goods_id=$_tmp_pinfo['goods_id'];
					      		}</php>
					      	<span>选择商户：</span>
					        <input id="search_partnerdesc" type="text" value="{:getParnterTitle($search_partner_id)}"
					        onclick="k_pop_syncSearch('search_partner_id'
					        													,'search_partnerdesc'
					        													,'选择商户'
					        													,'{:U('Admin://Partner/getJson')}'
					        													,function(){ $('#search_goodsdesc').click(); }
					        													,function(){ $('#search_goodsdesc').val('');$('#search_goods_id').val(''); })" 
					        readonly >
					        <input name="search_partner_id" id="search_partner_id" type="hidden" value="{$search_partner_id}">

					      	<span>选择商品：</span>
					        <input id="search_goodsdesc" type="text" value="{:getGoodsTitle($search_goods_id)}"
					        onclick="k_pop_syncSearch('search_goods_id'
					        													,'search_goodsdesc'
					        													,'选择商品'
					        													,'{:U('Admin://Goods/getJson',array('partner_id'=>''))}'+$('#search_partner_id').val()
					        													,null
					        													,null)" 
					        readonly >
					        
					    </dl>
					    <dl>
					    	<input type="submit" class="btn_b" value="搜索" />
					    	&nbsp;&nbsp;&nbsp;&nbsp;
					    	<input type="reset" class="btn_b" value="清空" />
					    </dl>
					</form>
					<div class="clear"></div>
			  </div>
		  </div>
		  <!-------- 搜索结束 -------->
		  
  <div class="page_tit">订单管理</div>
  <div class="Toolbar_inbox">
  		<a href="javascript:void(0);" class="btn_a" onclick="_show_searcharea();">
			<span>条件搜索</span>
		</a>
		<a href="javascript:void(0);" class="btn_a" onclick="show_del(this);" callback="doDelete();" title="设置选择的订单无效！"><span>订单无效</span></a>
		<php>if(C('ADMIN_OPEN_ORDER_CLEAN')){</php>
		<a href="javascript:void(0);" class="btn_a" onclick="ui.confirm(this,'将彻底删除对应的礼券、支付记录。删除成功后将无法恢复，确认继续？');" callback="doClean();" title="从数据库中彻底删除数据！"><span>彻底删除</span></a>
  		<php>}</php>
  </div>
  
  <div class="list">
  <table id="partner_list" width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
   <th style="width:30px;">
		<input type="checkbox" id="checkbox_handle" onclick="table_checkAll(this)" value="0">
    	<label for="checkbox"></label>
	</th>
	<th class="line_l">有效</th>
    <th class="line_l">订单编号</th>
    <th class="line_l">商品品牌</th>
    <th class="line_l">商品名称</th>
    <th class="line_l">购买单价</th>
    <th class="line_l">购买数量</th>
    <th class="line_l">送者名称</th>
    <th class="line_l">送者手机</th>
    <th class="line_l">是否支付</th>
    <th class="line_l">支付时间</th>
    <th class="line_l" style="text-align:center">操作</th>
  </tr>
  <volist id="vo" name="pagedata['data']">
  <php>	$tmp_product = getProductInfoByShelfId($vo['shelf_id']);
  		//dump($tmp_product);
  </php>
      <tr overstyle='on' id="{$vo.id}">
      	<td><input type="checkbox" name="checkbox" id="checkbox2" onclick="table_checkon(this)" value="{$vo.id}"></td>
        <td title="{$vo.remark}">{$vo.enable}</td>
        <td>{$vo.id}</td>
        
        <td>{$tmp_product['partner_title']}</td>
        <td>{$tmp_product['goods_title']}</td>
        
        <td>{$tmp_product['shelf_out_price']}</td>
        <td>{$vo['quantity']}</td>
        <td>{$vo['sender_name']}</td>
        <td>{$vo['sender_mobile']}</td>
        <td>{$vo['pay_state']}</td>
        <td>{:paramMillisecond2Date($vo['pay_time'],'Y-m-d H:i','-------- --:--')}</td>
        <td style="text-align:center">
        	<a href="javascript:void(0);" onclick="show_del(this);" callback="doDelete('{$vo['id']}');" >无效</a>&nbsp; 
            <a href="{:U('/Order/coupon',array('search_orderId'=>$vo['id']))}" >礼券</a>&nbsp; 
            <a href="{:U('/Payment/index',array('item_id'=>$vo['id'],'pay_type'=>'pay_order'))}" >支付</a>   
        </td>
      </tr>
  </volist>
  </table>

  </div>
  <div class="Toolbar_inbox">
    <div class="page_box">{$pagedata['html']}</div>
  </div>
</div>

<script>
	
    //鼠标移动表格效果
    $(document).ready(function(){
    	table_init();
    });
    
    function show_del(_this){
    	ui.confirm(_this,'将设置对应的礼券、支付记录失效。设置失效成功后将无法恢复，确认继续？'
				+'<br>失效原因：<input type=\'text\' '
						+'class=\'do_input s_input\'  style=\'width:180px;height: 20px; font-size: 12px;line-height: 20px;\' id=\'del_remark\'/>'
				);
    }
    
    //删除用户
	function doDelete(oid) {
		oid = oid ? oid : table_getChecked();
		oid = oid.toString();
		var del_remark = $('#del_remark').val();
		if(oid == '') {
			k_error('请选择要设置失效的订单！');
			return false;
		}
		if(del_remark==''){
			k_error('请输入失效原因！');
			return false;
		}
		
		$.post("{:U('/Order/doDelete')}", {oid:oid,remark:del_remark}, function(res){
			if(res == '1') {
				oid = oid.split(',');
				for(i = 0; i < oid.length; i++) {
					$('#'+oid[i]).remove();
				}
				ui.success('设置失效成功');
			}else {
				ui.error('设置实效失败');
			}
		});
	}
    
    
    //删除用户
	function doClean(oid) {
		oid = oid ? oid : table_getChecked();
		oid = oid.toString();
		if(oid == '') {
			k_error('请选择要删除的订单！');
			return false;
		}
		
		$.post("{:U('/Order/doClean')}", {oid:oid}, function(res){
			if(res == '1') {
				oid = oid.split(',');
				for(i = 0; i < oid.length; i++) {
					$('#'+oid[i]).remove();
				}
				ui.success('删除成功');
			}else {
				ui.error('删除失败');
			}
		});
	}
</script>

<include file="../Public/_footer.html" />